<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #box{
      width: 100px;
      height: 300px;
      overflow-y: scroll;
      background-color: #ddd;
    }
  </style>
</head>
<body>
  <div id="box">
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
    <h1>123</h1>
  </div>
</body>
</html>
<script>
  document.getElementById("box").addEventListener("scroll",function(){
    let scrollTop = document.getElementById("box").scrollTop;
    let clientHeight = document.getElementById("box").clientHeight;
    let scrollHeight = document.getElementById("box").scrollHeight;
    console.log("窗口可以滚动的高度:",scrollHeight);
    console.log("窗口的高度,",clientHeight);
    // console.log(scrollTop);
    console.log(scrollHeight-clientHeight-scrollTop);
  })
</script>